﻿namespace UFIDA.U9.Cust.U9Demo.DeliveryBP
{
    using DeliverBE;
    using System;
    using System.Collections.Generic;
    using System.Text;
    using UFSoft.UBF.AopFrame;
    using UFSoft.UBF.Util.Context;

    /// <summary>
    /// GetDefalueDocType partial 
    /// </summary>	
    public partial class GetDefalueDocType 
	{	
		internal BaseStrategy Select()
		{
			return new GetDefalueDocTypeImpementStrategy();	
		}		
	}
	
	#region  implement strategy	
	/// <summary>
	/// Impement Implement
	/// 
	/// </summary>	
	internal partial class GetDefalueDocTypeImpementStrategy : BaseStrategy
	{
		public GetDefalueDocTypeImpementStrategy() { }

		public override object Do(object obj)
		{						
			GetDefalueDocType bpObj = (GetDefalueDocType)obj;

            //get business operation context is as follows
            //IContext context = ContextManager.Context	

            //auto generating code end,underside is user custom code
            //and if you Implement replace this Exception Code...
            if (bpObj == null)
                return null;
            DocTypeDTO docDTO = new DocTypeDTO();
            StringBuilder oqlStr = new StringBuilder(256);
            if (bpObj.ID > 0)
            {
                oqlStr.Append(" ID=" + bpObj.ID + "");
            }
            else
            {
               
                oqlStr.Append("  Org=" + UFIDA.U9.Base.Context.LoginOrg.ID);
                oqlStr.Append(" and BizType=" + bpObj.Type.Value + "");
            }
            DocType docType = DocType.Finder.Find(oqlStr.ToString());
            if (docType != null)
            {
                docDTO.ID = docType.ID;
                docDTO.Code = docType.Code;
                docDTO.Name = docType.Name;
                docDTO.DocHeadSequenceStyle = Convert.ToInt16(docType.DocHeaderSequenceStyle.Value);
                docDTO.ApproveType = Convert.ToInt16(docType.ApproveType.Value);
            }
            return docDTO;
        }		
	}

	#endregion
	
	
}